package day6.wait_and_notify;

import java.util.concurrent.TimeUnit;
/**
 * wait和notify的先后顺序
 */
public class Demo4 {
    static Object o = new Object();

    static class MyThread extends Thread {
        @Override
        public void run() {
            synchronized (o) {
                System.out.println("notify");
                o.notify();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread t = new MyThread();
        t.start();

        TimeUnit.SECONDS.sleep(2);

        synchronized (o) {
            System.out.println("wait");
            o.wait();
        }
    }
}
